<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Canvas学习</title>
  <style>
    body {
      background: linear-gradient(to bottom, #000 0%, #5788fe 100%);
    }
    @keyframes colorChange {
      0%, 100% {
        opacity: 0;
      }
      50% {
        opacity: 0.9;
      }
    }
    .filter {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      background: #fe5757;
      animation: colorChange 30s ease-in-out infinite;
      animation-fill-mode: both;
      mix-blend-mode: overlay;
    }
    #canvas {
      background-color: #000;
      /* 如果使用 CSS 来设置宽高的话，画布就会按照 300 * 150 的比例进行缩放，也就是将 300 * 150 的页面显示在 400 * 400 的容器中。 */
      /* width: 400px;
      height: 400px; */
    }
  </style>
</head>
<body>
  <div class="filter"></div>
  <!-- <canvas id="canvas"></canvas> -->

  <script>
    var canvas = document.getElementById('canvas');
    canvas.width = 400
    canvas.height = 400
    var context = canvas.getContext('2d');
    
    context.fillStyle = 'white'
    context.rotate(20 * Math.PI / 100)
    context.fillRect(100, 100, 20, 10)
  </script>

</body>
</html>